<?php

namespace app\api\controller;

use think\Controller;
use think\Request;

class Student extends controller
{
    public function getStudentList(Request $request)
    {
        $page = $request->get('page', 1, 'intval');
        $page = $page > 0 ? $page : 1;
        $list = Db('student')
            ->field('student_id,article_id,name,avatar,company,position,description')
            ->order('sort asc')
            ->page($page, 10)
            ->select();
        return ['code' => 0, 'data' => $list];
    }

    public function getStudentInfo(Request $request)
    {
        $student_id = $request->get('student_id', 0, 'intval');
        $info = Db('student')
            ->where('student_id', $student_id)
            ->find();
        if (!$info) {
            return ['code' => 2, 'msg' => '案例已删除'];
        }
        return ['code' => 0, 'data' => $info];
    }
}
